"use strict";
cc._RF.push(module, '6ffafx022pDp4VB/BNzg5Xj', 'HallGoldSupply');
// scripts/HallGoldSupply.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
}), o.Supply_Type = void 0;
var r = t("GlobalUserData"),
    s = t("BroadCastMessage"),
    l = t("NativeManager"),
    c = t("Util"),
    d = t("WXSDK"),
    h = t("Global"),
    p = t("GoldFlyAnim"),
    u = t("HallConstant"),
    f = cc._decorator,
    m = f.ccclass,
    _ = f.property;
o.Supply_Type = {
  Gold: 1,
  Diamond: 2
};

var y = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.pfb_goldfly = null, e.node_Gold = null, e.node_Diamond = null, e.node_iconGold = null, e.node_iconDiamond = null, e.lab_curGold = null, e.lab_curVideo = null, e.lab_nextGold = null, e.lab_nextVideo = null, e.closeNode = null, e.btnClose = null, e.btnShowAd = null, e.videoIcon = null, e.TTVideoIcon = null, e.btnShowVideo = null, e.btnGet = null, e.btnCancel = null, e.mistakeBannerTimer = null, e.nGoldVideo = 0, e.nDiamondVideo = 0, e.nTotalGetGold = 0, e.nTotalGetDiamond = 0, e._closeCB = null, e._hallControl = null, e.nPrevDate = 0, e._supplyType = 0, e.isBtnClickOnce = !1, e;
  }

  return n(e, t), e.prototype.onLoad = function () {
    this.initLocalData();
  }, e.prototype.start = function () {
    var t = this;
    this.closeNode.active = !0, this.btnClose.active = !1, this.btnShowAd.active = !1, this.btnShowVideo.active = !1, this.btnCancel.active = !1, this.btnGet.x = 0, c.Util.is_tt() && (this.videoIcon.active = !1, this.TTVideoIcon.active = !0, c.Util.showBanner(), r["default"].bAuditMode ? (this.btnGet.x = 130, this.btnClose.active = !1, this.btnCancel.active = !0) : (this.btnShowVideo.active = !0, this.btnClose.active = !1, setTimeout(function () {
      t.closeNode.active = !0;
    }, 2e3))), c.Util.is_233() && l["default"].instance.showInterstitialAd(), c.Util.hideHallBanner();
    var e = r["default"].nTotalGame % 6;
    c.Util.showNativeBanner(1, this.btnShowAd, function () {
      c.Util.is_qg() && !r["default"].bAuditMode && r["default"].nativeMistakeBannerList[e] && (t.btnClose.active = !1, setTimeout(function () {
        t.closeNode.active = !0;
      }, 2e3));
    }), c.Util.hideSingleCustomAd(), c.Util.show_VerticalCustomAd(!1), c.Util.show_VerticalCustomAd(!0), r["default"].bAuditMode && c.Util.is_wx() || !r["default"].isShowMistakeBanner && c.Util.is_wx() ? c.Util.showBanner() : this.mistakeBannerTimer = setTimeout(function () {
      c.Util.showMistakeBanner(function () {
        t.mistakeBannerTimer = setTimeout(function () {
          c.Util.hideMistakeBanner(), c.Util.showBanner();
        }, 2e3);
      }, function () {
        c.Util.showBanner();
      });
    }, 1e3);
  }, e.prototype.initLocalData = function () {
    var t = c.Util.getCurDayDate(),
        e = cc.sys.localStorage.getItem("user_goldsupply_data");

    if (e) {
      var o = JSON.parse(e);
      this.nPrevDate = o.date || 0, this.nGoldVideo = o.gold || 0, this.nDiamondVideo = o.diamond || 0, t > this.nPrevDate && (this.nPrevDate = t, this.nGoldVideo = 0, this.nDiamondVideo = 0);
    } else this.nPrevDate = t, this.nGoldVideo = 0, this.nDiamondVideo = 0;
  }, e.prototype.saveLocalData = function () {
    var t = c.Util.getCurDayDate();
    t > this.nPrevDate && (this.nPrevDate = t, this.nGoldVideo = 0, this.nDiamondVideo = 0);
    var e = {
      gold: this.nGoldVideo,
      diamond: this.nDiamondVideo,
      date: this.nPrevDate
    };
    cc.sys.localStorage.setItem("user_goldsupply_data", JSON.stringify(e));
  }, e.prototype.initView = function (t, e, i) {
    this._supplyType = t, this._hallControl = e, this._closeCB = i, this.nTotalGetGold = 0, this.nTotalGetDiamond = 0, o.Supply_Type.Diamond == this._supplyType ? (this.node_Gold.active = !1, this.node_Diamond.active = !0, this.onSetLableDiamond(), this.videoTab = h.VideoTab.dim17) : (this.node_Gold.active = !0, this.node_Diamond.active = !1, this.onSetLable(), this.videoTab = h.VideoTab.dim16), c.Util.videoExposure(this.videoTab);
  }, e.prototype.onSetLableDiamond = function () {
    this.nTotalGetDiamond = this.getVideoDiamond(this.nDiamondVideo + 1), this.lab_curGold.string = c.Util.transformGoldStr(this.nTotalGetDiamond), this.lab_curVideo.string = (this.nDiamondVideo + 1).toString(), console.log("sadthis.nDiamondVideo：" + this.nDiamondVideo), this.nDiamondVideo + 1 > 10 ? this.btnGet.active = !1 : this.btnGet.active = !0, this.onSetNexLableDiamonde();
  }, e.prototype.onSetNexLableDiamonde = function () {
    var t = 5;
    t = this.nDiamondVideo + 1 < 5 ? 5 : this.nDiamondVideo + 1 < 10 ? 10 : this.nDiamondVideo + 1 <= 15 ? 15 : this.nDiamondVideo + 1, this.lab_nextGold.string = c.Util.transformGoldStr(this.getVideoDiamond(t)), this.lab_nextVideo.string = t.toString();
  }, e.prototype.getVideoDiamond = function (t) {
    var e = 200;
    return 0 == t ? e = 0 : 5 == t ? e = 500 : 10 == t ? e = 800 : 15 == t && (e = 500), e;
  }, e.prototype.onSetLable = function () {
    this.nTotalGetGold = this.getVideoGold(this.nGoldVideo + 1), this.lab_curGold.string = c.Util.transformGoldStr(this.nTotalGetGold), this.lab_curVideo.string = (this.nGoldVideo + 1).toString(), this.nGoldVideo + 1 > 10 ? this.btnGet.active = !1 : this.btnGet.active = !0, this.onSetNexLable();
  }, e.prototype.onSetNexLable = function () {
    var t = 5;
    t = this.nGoldVideo + 1 < 5 ? 5 : this.nGoldVideo + 1 < 10 ? 10 : this.nGoldVideo + 1 <= 15 ? 15 : this.nGoldVideo + 1, this.lab_nextGold.string = c.Util.transformGoldStr(this.getVideoGold(t)), this.lab_nextVideo.string = t.toString();
  }, e.prototype.getVideoGold = function (t) {
    var e = c.Util.itemHighestLevel() >= 10,
        o = 1e3 * Math.ceil(14 * Math.pow(c.Util.itemHighestLevel(), 3) / 1e3),
        i = e ? o : 8e3;
    return 0 == t ? i = 0 : 5 == t ? i = e ? Math.ceil(2.5 * o) : 2e4 : 10 == t ? i = e ? Math.ceil(4 * o) : 32e3 : 15 == t && (i = 2e4), i;
  }, e.prototype.onBtnClose = function () {
    this.isBtnClickOnce || r["default"].bAuditMode || !r["default"].isShowMistakeBanner || !c.Util.is_wx() ? (this.isBtnClickOnce = !1, clearTimeout(this.mistakeBannerTimer), this.playAudio(u.Audio_ID.btn_click), this._closeCB && this._closeCB(), this.node.destroy(), c.Util.hideBanner(), c.Util.hideMistakeBanner(), c.Util.showHallBanner(), c.Util.showSingleCustomAd(), c.Util.hide_VerticalCustomAd(!1), c.Util.hide_VerticalCustomAd(!0), c.Util.hideNativeBanner()) : this.isBtnClickOnce = !0;
  }, e.prototype.onClickNativeBanner = function () {
    c.Util.clickNativeBanner(2);
  }, e.prototype.onBtnVideoGet = function () {
    var t = this;
    this.playAudio(u.Audio_ID.btn_click), r["default"].videoTab = this.videoTab, c.Util.showRewardVideo(function () {
      o.Supply_Type.Diamond == t._supplyType ? (t.playGetDiamondAnim(), t.nDiamondVideo++, t.saveLocalData(), d["default"].getIntance().expt_GetDiamond(t.nTotalGetDiamond), r["default"].saveDiamondData(!0, t.nTotalGetDiamond), t.onSetLableDiamond()) : (t.playGetGoldAnim(), t.nGoldVideo++, t.saveLocalData(), d["default"].getIntance().expt_GetGold(t.nTotalGetGold), r["default"].saveGoldData(!0, t.nTotalGetGold), t.onSetLable());
    });
  }, e.prototype.playGetGoldAnim = function () {
    var t = this;
    this.playAudio(u.Audio_ID.get_gold);

    var e = this._hallControl.getGoldWorldPos();

    c.Util.AnimFly(p.Fly_Type.Gold, this.pfb_goldfly, this.node_iconGold, e, function () {
      t._hallControl.onSetOwnGold(!0);
    }, function () {});
  }, e.prototype.playGetDiamondAnim = function () {
    var t = this;
    this.playAudio(u.Audio_ID.get_gold);

    var e = this._hallControl.getDiamondWorldPos();

    c.Util.AnimFly(p.Fly_Type.Diammond, this.pfb_goldfly, this.node_iconDiamond, e, function () {
      t._hallControl.onSetOwnDiamond(!0);
    }, function () {});
  }, e.prototype.playAudio = function (t) {
    s["default"].getInstance().SendMessage(u.Broadcast_Func.Audio, t);
  }, a([_(cc.Prefab)], e.prototype, "pfb_goldfly", void 0), a([_(cc.Node)], e.prototype, "node_Gold", void 0), a([_(cc.Node)], e.prototype, "node_Diamond", void 0), a([_(cc.Node)], e.prototype, "node_iconGold", void 0), a([_(cc.Node)], e.prototype, "node_iconDiamond", void 0), a([_(cc.Label)], e.prototype, "lab_curGold", void 0), a([_(cc.Label)], e.prototype, "lab_curVideo", void 0), a([_(cc.Label)], e.prototype, "lab_nextGold", void 0), a([_(cc.Label)], e.prototype, "lab_nextVideo", void 0), a([_(cc.Node)], e.prototype, "closeNode", void 0), a([_(cc.Node)], e.prototype, "btnClose", void 0), a([_(cc.Node)], e.prototype, "btnShowAd", void 0), a([_(cc.Node)], e.prototype, "videoIcon", void 0), a([_(cc.Node)], e.prototype, "TTVideoIcon", void 0), a([_(cc.Node)], e.prototype, "btnShowVideo", void 0), a([_(cc.Node)], e.prototype, "btnGet", void 0), a([_(cc.Node)], e.prototype, "btnCancel", void 0), a([m], e);
}(cc.Component);

o["default"] = y;

cc._RF.pop();